home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / c-runtime / dispatch / RCS / Object.m,v < prev    next >
Encoding:
Text File  |  1992-08-18  |  22.0 KB  |  1,218 lines

  1. head    0.19;
  2. access;
  3. symbols;
  4. locks; strict;
  5. comment    @# @;
  6.  
  7.  
  8. 0.19
  9. date    92.04.18.01.11.50;    author dennisg;    state Exp;
  10. branches;
  11. next    0.18;
  12.  
  13. 0.18
  14. date    92.04.18.00.43.06;    author dennisg;    state Exp;
  15. branches;
  16. next    0.17;
  17.  
  18. 0.17
  19. date    92.04.13.11.43.08;    author dennisg;    state Exp;
  20. branches;
  21. next    0.16;
  22.  
  23. 0.16
  24. date    92.02.25.11.16.03;    author dennisg;    state Exp;
  25. branches;
  26. next    0.15;
  27.  
  28. 0.15
  29. date    92.01.03.02.55.03;    author dennisg;    state Exp;
  30. branches;
  31. next    0.14;
  32.  
  33. 0.14
  34. date    91.12.31.20.13.03;    author dennisg;    state Exp;
  35. branches;
  36. next    0.13;
  37.  
  38. 0.13
  39. date    91.12.10.12.04.55;    author dennisg;    state Exp;
  40. branches;
  41. next    0.12;
  42.  
  43. 0.12
  44. date    91.12.07.00.49.28;    author dennisg;    state Exp;
  45. branches;
  46. next    0.11;
  47.  
  48. 0.11
  49. date    91.12.06.00.35.05;    author dennisg;    state Exp;
  50. branches;
  51. next    0.10;
  52.  
  53. 0.10
  54. date    91.11.30.14.19.18;    author dennisg;    state Exp;
  55. branches;
  56. next    0.9;
  57.  
  58. 0.9
  59. date    91.11.29.21.59.32;    author dennisg;    state Exp;
  60. branches;
  61. next    0.8;
  62.  
  63. 0.8
  64. date    91.11.29.20.01.29;    author dennisg;    state Exp;
  65. branches;
  66. next    0.7;
  67.  
  68. 0.7
  69. date    91.11.29.14.09.51;    author dennisg;    state Exp;
  70. branches;
  71. next    0.6;
  72.  
  73. 0.6
  74. date    91.11.26.02.45.16;    author dennisg;    state Exp;
  75. branches;
  76. next    0.5;
  77.  
  78. 0.5
  79. date    91.11.20.02.06.30;    author dennisg;    state Exp;
  80. branches;
  81. next    0.4;
  82.  
  83. 0.4
  84. date    91.11.19.12.37.24;    author dennisg;    state Exp;
  85. branches;
  86. next    0.3;
  87.  
  88. 0.3
  89. date    91.11.16.13.32.58;    author dennisg;    state Exp;
  90. branches;
  91. next    0.2;
  92.  
  93. 0.2
  94. date    91.11.07.22.30.54;    author dennisg;    state Exp;
  95. branches;
  96. next    0.1;
  97.  
  98. 0.1
  99. date    91.10.24.00.45.39;    author dennisg;    state Exp;
  100. branches;
  101. next    ;
  102.  
  103.  
  104. desc
  105. @This is the implementation file for class Object.
  106. Much of its functionality was coded from descriptions
  107. contained within the NeXT technical documentation and
  108. from "Object-Oriented Programming", Second Edition, by
  109. Cox and Novobilski.
  110. @
  111.  
  112.  
  113. 0.19
  114. log
  115. @changes some name accesses to use functions.
  116. @
  117. text
  118. @/* -*-c-*-
  119.  * This file contains the implementation of class Object.
  120.  *
  121.  * Copyright (C) 1991 Threaded Technologies Inc.
  122.  * 
  123.  * This program is free software; you can redistribute it and/or modify
  124.  * it under the terms of the GNU General Public License as published
  125.  * by the Free Software Foundation; either version 1, or any later version.
  126.  * 
  127.  * This program is distributed in the hope that it will be useful,
  128.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  129.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  130.  * General Public License for more details.
  131.  * 
  132.  * You should receive a copy of the GNU General Public License 
  133.  * along with this program; if not, write to the Free Software
  134.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  135.  * 
  136.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/dispatch.common/RCS/Object.m,v 0.18 1992/04/18 00:43:06 dennisg Exp dennisg $
  137.   $Author: dennisg $
  138.   $Date: 1992/04/18 00:43:06 $
  139.   $Log: Object.m,v $
  140. # Revision 0.18  1992/04/18  00:43:06  dennisg
  141. # Changed -hash.
  142. # It returned 'self' casted to a unsigned int.
  143. #
  144. # Revision 0.17  1992/04/13  11:43:08  dennisg
  145. # Check in after array version of run-time works.
  146. # Expect more changes as hash version and other changes are made.
  147. #
  148. # Revision 0.16  1992/02/25  11:16:03  dennisg
  149. # ??? I lost track.
  150. #
  151. # Revision 0.15  1992/01/03  02:55:03  dennisg
  152. # modified to handle new initialization scheme.
  153. # fixed code structure.
  154. #
  155. # Revision 0.14  1991/12/31  20:13:03  dennisg
  156. # Deleted index variable stuff.  Index variables are a hack to the language.
  157. #
  158. # Revision 0.13  1991/12/10  12:04:55  dennisg
  159. # Cleaned up file format for a distribution.
  160. #
  161. # Revision 0.12  1991/12/07  00:49:28  dennisg
  162. # deleted +description:.
  163. #
  164. # Revision 0.11  1991/12/06  00:35:05  dennisg
  165. # deleted perform:with:: method.
  166. # changes the other perform: methods to use objc_msgSend() correctly.
  167. #
  168. # Revision 0.10  1991/11/30  14:19:18  dennisg
  169. # implemented archiving.
  170. #
  171. # Revision 0.9  1991/11/29  21:59:32  dennisg
  172. # modified to implement set functions.
  173. #
  174. # Revision 0.8  1991/11/29  20:01:29  dennisg
  175. # fixed several const decls.  bozo.
  176. #
  177. # Revision 0.7  1991/11/29  14:09:51  dennisg
  178. # changed some methods to implement functions contained in the core code.
  179. #
  180. # Revision 0.6  1991/11/26  02:45:16  dennisg
  181. # commiting a copy of the source to rcs before i implement
  182. # changes to fix posing.
  183. #
  184. # Revision 0.5  1991/11/20  02:06:30  dennisg
  185. # returned doesNotRecognize:
  186. #
  187. # Revision 0.4  1991/11/19  12:37:24  dennisg
  188. # minr changes.  still in a state of flux.
  189. #
  190. # Revision 0.3  1991/11/16  13:32:58  dennisg
  191. # changed #import statements to #include.
  192. # this should make gcc2 happy -- geez.
  193. #
  194. # Revision 0.2  1991/11/07  22:30:54  dennisg
  195. # added copyleft
  196. #
  197. # Revision 0.1  1991/10/24  00:45:39  dennisg
  198. # Initial check in.  Preliminary development stage.
  199. #
  200. */
  201.  
  202.  
  203. #include <Object.h>
  204. #include <objc-proto.h>
  205. #include <objc-protoP.h>
  206.  
  207. #include <errno.h>
  208. #include <stdarg.h>
  209. #include <stdlib.h>
  210.  
  211.  
  212. #define CLASS( class )  (( Class_t )class )
  213.  
  214.  
  215. @@implementation Object
  216.  
  217.  
  218. + new {
  219.  
  220.  
  221.   return class_createInstance( CLASS( self ));
  222. }
  223.  
  224.  
  225. + free {  return nil; }
  226. - free {  return object_dispose( self ); }
  227.  
  228.  
  229. - copy {  return [ self shallowCopy ]; }
  230.  
  231.  
  232. - shallowCopy {
  233.  
  234.  
  235.   return object_copy ( self );
  236. }
  237.  
  238.  
  239. - deepCopy {
  240.  
  241.   
  242.   return class_createInstance ([ self class ]);
  243. }
  244.  
  245.  
  246. + ( Class_t )class      { return CLASS( self ); }
  247. + ( Class_t )superClass { return CLASS( self )->super_class; }
  248. - ( Class_t )class      { return isa; }
  249. - ( Class_t )superClass { return isa->super_class; }
  250. - ( const char * )name  { return object_getClassName (self); }
  251. - self                  { return self; }
  252.  
  253.  
  254. - ( u_int )hash {
  255.  
  256.   
  257.   return ( u_int )self; /* gak!  Not portable. */
  258. }
  259.  
  260.  
  261. - ( BOOL )isEqual:anObject {
  262.  
  263.   
  264.   return self == anObject ;
  265. }
  266.  
  267.  
  268. - ( BOOL )isKindOf:( Class_t )aClassObject {
  269.  
  270.  
  271.   return [ self isKindOfGivenName:class_getClassName (aClassObject)];
  272. }
  273.  
  274.  
  275. - ( BOOL )isMemberOf:( Class_t )aClassObject {
  276.  
  277.  
  278.   return isa == aClassObject ;
  279. }
  280.  
  281.  
  282. - ( BOOL )isKindOfGivenName:( const char* )aClassName {
  283.  
  284.   Class_t   class;
  285.   
  286.   
  287.   for( class = isa; class; class = class->super_class )
  288.     if( !strcmp( class_getClassName (class), aClassName ))
  289.       return YES;
  290.   
  291.   return NO;
  292. }
  293.  
  294.  
  295. - ( BOOL )isMemberOfGivenName:( const char* )aClassName {
  296.  
  297.  
  298.   return !strcmp([ self name ], aClassName );
  299. }
  300.  
  301.  
  302. + ( BOOL )instancesRespondTo:( SEL )aSel {
  303.  
  304.   
  305.   if( class_getInstanceMethod( CLASS( self ), aSel ))
  306.     return YES;
  307.   
  308.   return NO;
  309. }
  310.  
  311.  
  312. - ( BOOL )respondsTo:( SEL )aSel {
  313.  
  314.  
  315.   if( class_getInstanceMethod( isa, aSel ))
  316.     return YES;
  317.  
  318.   return NO;
  319. }
  320.  
  321.  
  322. - perform:( SEL )aSel {
  323.  
  324.   
  325.   return (*((IMP)objc_msgSend( self, aSel )))(self, aSel);
  326. }
  327.  
  328.  
  329. - perform:( SEL )aSel with:aObject {
  330.  
  331.   
  332.   return (*((IMP)objc_msgSend( self, aSel )))(self, aSel, aObject);
  333. }
  334.  
  335.  
  336. + poseAs:( Class_t )aClassObject {
  337.  
  338.  
  339.   return class_poseAs (self, aClassObject);
  340. }
  341.  
  342.  
  343. - subclassResponsibility:( SEL )aSel {
  344.  
  345.   
  346.   return [ self error:"subclass should override %s", aSel ];
  347. }
  348.  
  349.  
  350. - notImplemented:(SEL)aSel {
  351.  
  352.  
  353.   return [ self error:"method %s not implemented", aSel ];
  354. }
  355.  
  356.  
  357. - doesNotRecognize:( SEL )aSel {
  358.  
  359.  
  360.   return [ self error:"%s does not recognize %s", [ self name ], aSel ];
  361. }
  362.  
  363. - error:( const char* )aString, ... {
  364.  
  365. #define FMT "error: %s (instance)\n%s\n"
  366.  
  367.   char  fmt[ strlen (FMT) + 
  368.               strlen (isa->name) +
  369.               strlen (aString) + 8 ];
  370.   va_list ap;
  371.   
  372.   
  373.   sprintf (fmt, FMT, isa->name, aString);
  374.   va_start (ap, aString);
  375.   (*_error)(self, fmt, ap);
  376.   va_end (ap);
  377.  
  378. #undef FMT
  379.   return self;
  380. }
  381.  
  382.  
  383. + error:( const char* )aString, ... {
  384.  
  385. #define FMT "error: %s (class)\n%s\n"
  386.  
  387.   char  fmt[ strlen (FMT) + 
  388.               strlen (isa->name) +
  389.               strlen (aString) + 8 ];
  390.   va_list ap;
  391.   
  392.   
  393.   sprintf (fmt, FMT, isa->name, aString);
  394.   va_start (ap, aString);
  395.   (*_error)(self, fmt, ap);
  396.   va_end (ap);
  397.  
  398. #undef FMT
  399.   return self;
  400. }
  401.  
  402.  
  403. - storeOn:( int )aFd {
  404.  
  405.   int   len;
  406.   long  version = [[ self class ] version ];
  407.   
  408.   
  409.   if ((len = write (aFd, "#", strlen ("#"))) != -1)
  410.     if ((len = write (aFd, [ self name ], strlen ([ self name ]) + 1)) != -1)
  411.       len = write (aFd, &version, sizeof (version));
  412.   
  413.   if (len == -1)
  414.     [ self error:"error passivating object, errno=%d", errno ];
  415.  
  416.   return self;
  417. }
  418.  
  419.  
  420. + readFrom:( int )aFd {
  421.  
  422.   id    aObj = nil;
  423.   char  objName[256];
  424.   int   len;
  425.   
  426.   
  427.   if ((len = read (aFd, &objName, strlen ("#"))) != -1)
  428.     if (objName[0] == '#') {
  429.       long  version;
  430.       int   i = 0;
  431.       
  432.                                                 /* Read the object's class. */
  433.       do {
  434.         len = read (aFd, &objName[i], sizeof (char));
  435.       } while (objName[ i++ ] && (len != -1));
  436.     
  437.                                                 /* Get its version. */
  438.       if (len != -1)
  439.         len = read (aFd, &version, sizeof (version));
  440.       
  441.                                                 /* No errors???
  442.                                                   Then create a object. */
  443.       if (len != -1) {
  444.           aObj = class_createInstance (objc_getClass (objName));
  445.           
  446.                                                 /* If the object was 
  447.                                                   successfully created then
  448.                                                   tell it to dearchive
  449.                                                   itself. */
  450.           if (aObj)
  451.             [ aObj readFrom:aFd ];
  452.       }
  453.     }
  454.     
  455.   if (len == -1)
  456.     [ self error:"error activating object, errno=%d", errno ];
  457.   
  458.   return aObj;
  459. }
  460.  
  461.  
  462. - readFrom:( int )aFd { return self; }
  463.  
  464.  
  465. + ( int )version {
  466.  
  467.  
  468.   return class_getVersion (CLASS (self));
  469. }
  470.  
  471.  
  472. + setVersion:( int )aVersion {
  473.  
  474.  
  475.   class_setVersion (CLASS (self), aVersion);
  476.   
  477.   return self;
  478. }
  479.  
  480.  
  481. @@end
  482.  
  483.  
  484. @
  485.  
  486.  
  487. 0.18
  488. log
  489. @Changed -hash.
  490. It returned 'self' casted to a unsigned int.
  491. @
  492. text
  493. @d19 1
  494. a19 1
  495.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/dispatch.common/RCS/Object.m,v 0.17 1992/04/13 11:43:08 dennisg Exp dennisg $
  496. d21 1
  497. a21 1
  498.   $Date: 1992/04/13 11:43:08 $
  499. d23 4
  500. d154 1
  501. a154 1
  502.   return [ self isKindOfGivenName:aClassObject->name ];
  503. d171 1
  504. a171 1
  505.     if( !strcmp( class->name, aClassName ))
  506. @
  507.  
  508.  
  509. 0.17
  510. log
  511. @Check in after array version of run-time works.
  512. Expect more changes as hash version and other changes are made.
  513. @
  514. text
  515. @d19 1
  516. a19 1
  517.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/common/RCS/Object.m,v 0.16 1992/02/25 11:16:03 dennisg Exp dennisg $
  518. d21 1
  519. a21 1
  520.   $Date: 1992/02/25 11:16:03 $
  521. d23 4
  522. d136 1
  523. a136 2
  524.   /* Cast the return value to prevent a compiler warning. */
  525.   return ( u_int )[ self subclassResponsibility:_cmd ];
  526. @
  527.  
  528.  
  529. 0.16
  530. log
  531. @??? I lost track.
  532. @
  533. text
  534. @d19 1
  535. a19 1
  536.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.15 1992/01/03 02:55:03 dennisg Exp dennisg $
  537. d21 1
  538. a21 1
  539.   $Date: 1992/01/03 02:55:03 $
  540. d23 3
  541. d79 2
  542. a80 2
  543. #include <ObjC-proto.h>
  544. #include <ObjC-proto-private.h>
  545. a320 1
  546.           aObj = object_realloc (aObj, objc_classSize (aObj));
  547. @
  548.  
  549.  
  550. 0.15
  551. log
  552. @modified to handle new initialization scheme.
  553. fixed code structure.
  554. @
  555. text
  556. @d19 1
  557. a19 1
  558.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.14 1991/12/31 20:13:03 dennisg Exp dennisg $
  559. d21 1
  560. a21 1
  561.   $Date: 1991/12/31 20:13:03 $
  562. d23 4
  563. a77 1
  564. #include <hash.h>
  565. @
  566.  
  567.  
  568. 0.14
  569. log
  570. @Deleted index variable stuff.  Index variables are a hack to the language.
  571. @
  572. text
  573. @d19 1
  574. a19 1
  575.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.13 1991/12/10 12:04:55 dennisg Exp dennisg $
  576. d21 1
  577. a21 1
  578.   $Date: 1991/12/10 12:04:55 $
  579. d23 3
  580. a76 1
  581. #include <libc.h>
  582. d78 1
  583. d126 1
  584. a126 1
  585.     /* Cast the return value to prevent a compiler warning. */
  586. @
  587.  
  588.  
  589. 0.13
  590. log
  591. @Cleaned up file format for a distribution.
  592. @
  593. text
  594. @d19 1
  595. a19 1
  596.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.12 1991/12/07 00:49:28 dennisg Exp dennisg $
  597. d21 1
  598. a21 1
  599.   $Date: 1991/12/07 00:49:28 $
  600. d23 3
  601. d73 1
  602. d87 1
  603. a87 1
  604.   return class_createInstance( CLASS( self ), [ self ndxVarSize ]);
  605. d101 1
  606. a101 1
  607.   return object_copy (self, [[ self class ] ndxVarSize ]);
  608. d108 1
  609. a108 1
  610.   return class_createInstance ([ self class ], [[ self class ] ndxVarSize ]);
  611. d123 2
  612. a124 1
  613.   return [ self subclassResponsibility:_cmd ];
  614. d311 2
  615. a312 3
  616.           aObj = class_createInstance 
  617.                     ( objc_getClass (objName), 0);
  618.           aObj = object_realloc (aObj, [[ aObj class ] ndxVarSize ]);
  619. a347 3
  620.  
  621. - ( u_int )capacity   { return 0; }
  622. + ( int )ndxVarSize   { return 0; }
  623. @
  624.  
  625.  
  626. 0.12
  627. log
  628. @deleted +description:.
  629. @
  630. text
  631. @d19 1
  632. a19 1
  633.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.11 1991/12/06 00:35:05 dennisg Exp dennisg $
  634. d21 1
  635. a21 1
  636.   $Date: 1991/12/06 00:35:05 $
  637. d23 3
  638. d87 2
  639. a88 2
  640. + free {    return nil; }
  641. - free {    return object_dispose( self ); }
  642. d91 1
  643. a91 1
  644. - copy {    return [ self shallowCopy ]; }
  645. d108 6
  646. a113 6
  647. + ( Class_t )class             {    return CLASS( self ); }
  648. + ( Class_t )superClass    {    return CLASS( self )->super_class; }
  649. - ( Class_t )class            {    return isa; }
  650. - ( Class_t )superClass    {    return isa->super_class; }
  651. - ( const char * )name    {    return object_getClassName (self); }
  652. - self                                    {    return self; }
  653. d133 1
  654. a133 1
  655.     return [ self isKindOfGivenName:aClassObject->name ];
  656. d186 2
  657. a187 2
  658.     
  659.     return (*((IMP)objc_msgSend( self, aSel )))(self, aSel);
  660. d193 2
  661. a194 2
  662.     
  663.     return (*((IMP)objc_msgSend( self, aSel )))(self, aSel, aObject);
  664. d208 1
  665. a208 1
  666.     return [ self error:"subclass should override %s", aSel ];
  667. d215 1
  668. a215 1
  669.     return [ self error:"method %s not implemented", aSel ];
  670. d227 1
  671. a227 1
  672. #define FMT    "error: %s (instance)\n%s\n"
  673. d229 3
  674. a231 3
  675.     char    fmt[ strlen (FMT) + 
  676.                             strlen (isa->name) +
  677.                             strlen (aString) + 8 ];
  678. d235 1
  679. a235 1
  680.     sprintf (fmt, FMT, isa->name, aString);
  681. d237 1
  682. a237 1
  683.     (*_error)(self, fmt, ap);
  684. d247 1
  685. a247 1
  686. #define FMT    "error: %s (class)\n%s\n"
  687. d249 3
  688. a251 3
  689.     char    fmt[ strlen (FMT) + 
  690.                             strlen (isa->name) +
  691.                             strlen (aString) + 8 ];
  692. d255 1
  693. a255 1
  694.     sprintf (fmt, FMT, isa->name, aString);
  695. d257 1
  696. a257 1
  697.     (*_error)(self, fmt, ap);
  698. d267 10
  699. a276 10
  700.     int        len;
  701.     long    version = [[ self class ] version ];
  702.     
  703.     
  704.     if ((len = write (aFd, "#", strlen ("#"))) != -1)
  705.         if ((len = write (aFd, [ self name ], strlen ([ self name ]) + 1)) != -1)
  706.             len = write (aFd, &version, sizeof (version));
  707.     
  708.     if (len == -1)
  709.         [ self error:"error passivating object, errno=%d", errno ];
  710. d284 38
  711. a321 38
  712.     id        aObj = nil;
  713.     char    objName[256];
  714.     int        len;
  715.     
  716.     
  717.     if ((len = read (aFd, &objName, strlen ("#"))) != -1)
  718.         if (objName[0] == '#') {
  719.             long    version;
  720.             int        i = 0;
  721.             
  722.                                                                                                 /* Read the object's class. */
  723.             do {
  724.                 len = read (aFd, &objName[i], sizeof (char));
  725.             } while (objName[ i++ ] && (len != -1));
  726.         
  727.                                                                                                 /* Get its version. */
  728.             if (len != -1)
  729.                 len = read (aFd, &version, sizeof (version));
  730.             
  731.                                                                                                 /* No errors???
  732.                                                                                                     Then create a object. */
  733.             if (len != -1) {
  734.                   aObj = class_createInstance 
  735.                                         ( objc_getClass (objName), 0);
  736.                     aObj = object_realloc (aObj, [[ aObj class ] ndxVarSize ]);
  737.                     
  738.                                                                                                 /* If the object was 
  739.                                                                                                     successfully created then
  740.                                                                                                     tell it to dearchive
  741.                                                                                                     itself. */
  742.                     if (aObj)
  743.                         [ aObj readFrom:aFd ];
  744.             }
  745.         }
  746.         
  747.     if (len == -1)
  748.         [ self error:"error activating object, errno=%d", errno ];
  749.     
  750. d326 1
  751. a326 1
  752. - readFrom:( int )aFd {    return self; }
  753. d332 1
  754. a332 1
  755.     return class_getVersion (CLASS (self));
  756. d339 2
  757. a340 2
  758.     class_setVersion (CLASS (self), aVersion);
  759.     
  760. d345 2
  761. a346 2
  762. - ( u_int )capacity        {    return 0; }
  763. + ( int )ndxVarSize        {    return 0; }
  764. @
  765.  
  766.  
  767. 0.11
  768. log
  769. @deleted perform:with:: method.
  770. changes the other perform: methods to use objc_msgSend() correctly.
  771. @
  772. text
  773. @d19 1
  774. a19 1
  775.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.10 1991/11/30 14:19:18 dennisg Exp dennisg $
  776. d21 1
  777. a21 1
  778.   $Date: 1991/11/30 14:19:18 $
  779. d23 4
  780. a343 1
  781. + ( STR )describe            {    return ""; }
  782. @
  783.  
  784.  
  785. 0.10
  786. log
  787. @implemented archiving.
  788. @
  789. text
  790. @d19 1
  791. a19 1
  792.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.9 1991/11/29 21:59:32 dennisg Exp dennisg $
  793. d21 1
  794. a21 1
  795.   $Date: 1991/11/29 21:59:32 $
  796. d23 3
  797. d179 2
  798. a180 2
  799.  
  800.   return objc_msgSend( self, aSel );
  801. d184 1
  802. a184 1
  803. - perform:( SEL )aSel with:anObject {
  804. d186 2
  805. a187 9
  806.  
  807.   return objc_msgSend( self, aSel, anObject );
  808. }
  809.  
  810.  
  811. - perform:( SEL )aSel with:object1 with:object2 {
  812.  
  813.  
  814.   return objc_msgSend( self, aSel, object1, object2 );
  815. @
  816.  
  817.  
  818. 0.9
  819. log
  820. @modified to implement set functions.
  821. @
  822. text
  823. @d19 1
  824. a19 1
  825.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.8 1991/11/29 20:01:29 dennisg Exp dennisg $
  826. d21 1
  827. a21 1
  828.   $Date: 1991/11/29 20:01:29 $
  829. d23 3
  830. d73 1
  831. a73 1
  832.   return class_createInstance( CLASS( self ), 0 );
  833. d77 2
  834. a78 1
  835. + free {
  836. d81 1
  837. a81 2
  838.   return nil;
  839. }
  840. d84 1
  841. a84 1
  842. - free {
  843. d87 1
  844. a87 1
  845.   return object_dispose( self );
  846. a90 13
  847. - copy {
  848.  
  849.  
  850.     return [ self shallowCopy ];
  851. }
  852.  
  853.  
  854. - shallowCopy {
  855.  
  856.   return object_copy (self, 0);
  857. }
  858.  
  859.  
  860. d94 1
  861. a94 1
  862.   return class_createInstance( isa, 0 );
  863. d98 6
  864. a103 1
  865. + ( Class_t )class {
  866. a104 3
  867.   
  868.   return CLASS( self );
  869. }
  870. a105 36
  871.  
  872. + ( Class_t )superClass {
  873.  
  874.  
  875.   return CLASS( self )->super_class;
  876. }
  877.  
  878.  
  879. - ( Class_t )class {
  880.  
  881.  
  882.   return isa;
  883. }
  884.  
  885.  
  886. - ( Class_t )superClass {
  887.  
  888.  
  889.   return isa->super_class;
  890. }
  891.  
  892.  
  893. - ( const char * )name {
  894.  
  895.  
  896.   return object_getClassName (self);
  897. }
  898.  
  899.  
  900. - self {
  901.  
  902.  
  903.   return self;
  904. }
  905.  
  906.  
  907. d262 1
  908. a262 1
  909. - awake {
  910. d264 10
  911. d279 1
  912. a279 1
  913. - write:( int)aFd {
  914. d281 39
  915. a319 2
  916.  
  917.   return [ self notImplemented:_cmd ];
  918. d323 1
  919. a323 1
  920. - read:( int )aFd {
  921. a325 4
  922.   return [ self notImplemented:_cmd ];
  923. }
  924.  
  925.  
  926. d341 4
  927. @
  928.  
  929.  
  930. 0.8
  931. log
  932. @fixed several const decls.  bozo.
  933. @
  934. text
  935. @d19 1
  936. a19 1
  937.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.7 1991/11/29 14:09:51 dennisg Exp dennisg $
  938. d21 1
  939. a21 1
  940.   $Date: 1991/11/29 14:09:51 $
  941. d23 3
  942. a56 1
  943. #include <memory.h>
  944. d84 1
  945. a84 1
  946.   return class_destroyInstance( self );
  947. d97 1
  948. a97 6
  949.   id  aCopy = class_createInstance( isa, 0 );
  950.  
  951.  
  952.   memcpy( aCopy, self, isa->instance_size );
  953.   
  954.   return aCopy;
  955. d268 5
  956. d276 4
  957. a279 5
  958.   va_start( ap, aString );
  959.   fprintf( stderr, "error: %s (instance)\n", isa->name);
  960.   vfprintf( stderr, aString, ap );
  961.   fprintf( stderr, "\n" );
  962.   va_end( ap );
  963. d281 1
  964. a281 2
  965.   abort();
  966.     
  967. d288 5
  968. d296 4
  969. a299 5
  970.   va_start( ap, aString );
  971.   fprintf( stderr, "error: %s (class)\n", isa->name);
  972.   vfprintf( stderr, aString, ap );
  973.   fprintf( stderr, "\n" );
  974.   va_end( ap );
  975. d301 1
  976. a301 2
  977.     abort();
  978.  
  979. @
  980.  
  981.  
  982. 0.7
  983. log
  984. @changed some methods to implement functions contained in the core code.
  985. @
  986. text
  987. @d19 1
  988. a19 1
  989.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.6 1991/11/26 02:45:16 dennisg Exp dennisg $
  990. d21 1
  991. a21 1
  992.   $Date: 1991/11/26 02:45:16 $
  993. d23 3
  994. d181 1
  995. a181 1
  996. - ( BOOL )isKindOfGivenName:( STR )aClassName {
  997. d194 1
  998. a194 1
  999. - ( BOOL )isMemberOfGivenName:( STR )aClassName {
  1000. d269 1
  1001. a269 1
  1002. - error:( STR )aString, ... {
  1003. d286 1
  1004. a286 1
  1005. + error:( STR )aString, ... {
  1006. @
  1007.  
  1008.  
  1009. 0.6
  1010. log
  1011. @commiting a copy of the source to rcs before i implement
  1012. changes to fix posing.
  1013. @
  1014. text
  1015. @d19 1
  1016. a19 1
  1017.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.5 1991/11/20 02:06:30 dennisg Exp dennisg $
  1018. d21 1
  1019. a21 1
  1020.   $Date: 1991/11/20 02:06:30 $
  1021. d23 4
  1022. d324 1
  1023. a324 1
  1024.   return CLASS( objc_getClass( class_getClassName( CLASS( self ))))->version;
  1025. d331 2
  1026. a332 3
  1027.   CLASS( objc_getClass( class_getClassName( CLASS( self ))))->version = 
  1028.         aVersion;
  1029.  
  1030. @
  1031.  
  1032.  
  1033. 0.5
  1034. log
  1035. @returned doesNotRecognize:
  1036. @
  1037. text
  1038. @d19 1
  1039. a19 1
  1040.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.4 1991/11/19 12:37:24 dennisg Exp dennisg $
  1041. d21 1
  1042. a21 1
  1043.   $Date: 1991/11/19 12:37:24 $
  1044. d23 3
  1045. d135 1
  1046. a135 1
  1047.   return isa->name;
  1048. d238 1
  1049. a238 1
  1050.   return [ self notImplemented:_cmd ];
  1051. @
  1052.  
  1053.  
  1054. 0.4
  1055. log
  1056. @minr changes.  still in a state of flux.
  1057. @
  1058. text
  1059. @d19 1
  1060. a19 1
  1061.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.3 1991/11/16 13:32:58 dennisg Exp dennisg $
  1062. d21 1
  1063. a21 1
  1064.   $Date: 1991/11/16 13:32:58 $
  1065. d23 3
  1066. d252 6
  1067. @
  1068.  
  1069.  
  1070. 0.3
  1071. log
  1072. @changed #import statements to #include.
  1073. this should make gcc2 happy -- geez.
  1074. @
  1075. text
  1076. @d19 1
  1077. a19 1
  1078.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.2 1991/11/07 22:30:54 dennisg Exp dennisg $
  1079. d21 1
  1080. a21 1
  1081.   $Date: 1991/11/07 22:30:54 $
  1082. d23 4
  1083. d37 1
  1084. a37 1
  1085. #include <ObjC-proto-hack.h>
  1086. d75 7
  1087. d91 7
  1088. d108 1
  1089. a108 4
  1090.   if( CLASS( self )->super_class )
  1091.     objc_getClass( CLASS( self )->super_class );
  1092.   else
  1093.     return nil;
  1094. d150 1
  1095. a150 1
  1096.   return ( self == anObject );
  1097. d157 1
  1098. a157 4
  1099.   if( aClassObject )
  1100.     return [ self isKindOfGivenName:class_getClassName( aClassObject )];
  1101.   else
  1102.     return nil;
  1103. d173 2
  1104. a174 2
  1105.   for( class = isa; class; class = objc_getClass( class->super_class ))
  1106.     if( !strcmp( class_getClassName( class ), aClassName ))
  1107. a207 33
  1108. - ( IMP )methodFor:( SEL )aSel {
  1109.  
  1110.   Method_t  theMethod;
  1111.   
  1112.   
  1113.   theMethod = class_getInstanceMethod( self->isa, aSel );
  1114.   
  1115.   if( theMethod )
  1116.     return theMethod->method_imp;
  1117.   else
  1118.     [ self error:"%s: does not respond to \"%s\".", [ self name ], aSel ];    
  1119.   
  1120.   return NULL;
  1121. }
  1122.  
  1123.  
  1124. + ( IMP )instanceMethodFor:( SEL )aSel {
  1125.  
  1126.   Method_t  theMethod;
  1127.   
  1128.   
  1129.   theMethod = class_getInstanceMethod( CLASS( self ), aSel );
  1130.   
  1131.   if( theMethod )
  1132.     return theMethod->method_imp;
  1133.   else
  1134.     [ self error:"%s does not respond to %s.", 
  1135.             class_getClassName( CLASS( self )), aSel ];    
  1136.   
  1137.   return NULL;
  1138. }
  1139.  
  1140.  
  1141. d239 1
  1142. a239 2
  1143.   return [ self error:" %s: Subclass should override message \"%s\".", 
  1144.             [ self name ], aSel ];
  1145. d246 1
  1146. a246 2
  1147.  
  1148.   return [ self error:"%s: hasn't implemented \"%s\".", [ self name ], aSel ];
  1149. a249 7
  1150. - doesNotRecognize:( SEL )aSel {
  1151.  
  1152.  
  1153.   return [ self error:"%s: does not recognize \"%s\".", [ self name ], aSel ];
  1154. }
  1155.  
  1156.  
  1157. d256 1
  1158. a256 1
  1159.   fprintf( stderr, "instance %s: incurred an error.\n", [ self name ]);
  1160. d260 3
  1161. a262 1
  1162.   
  1163. d273 1
  1164. a273 2
  1165.   fprintf( stderr, "class %s: incurred an error.\n", 
  1166.                       class_getClassName( CLASS( self )));
  1167. d278 2
  1168. d308 1
  1169. a308 1
  1170.   return _objc_getClass( class_getClassName( CLASS( self )))->version;
  1171. d315 2
  1172. a316 1
  1173.   _objc_getClass( class_getClassName( CLASS( self )))->version = aVersion;
  1174. @
  1175.  
  1176.  
  1177. 0.2
  1178. log
  1179. @added copyleft
  1180. @
  1181. text
  1182. @d19 1
  1183. a19 1
  1184.   $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/Object.m,v 0.1 1991/10/24 00:45:39 dennisg Exp dennisg $
  1185. d21 1
  1186. a21 1
  1187.   $Date: 1991/10/24 00:45:39 $
  1188. d23 3
  1189. d32 4
  1190. a35 4
  1191. #import <Object.h>
  1192. #import <ObjC-proto-hack.h>
  1193. #import <ObjC-proto-private.h>
  1194. #import <hash.h>
  1195. d37 3
  1196. a39 3
  1197. #import <memory.h>
  1198. #import <libc.h>
  1199. #import <stdarg.h>
  1200. @
  1201.  
  1202.  
  1203. 0.1
  1204. log
  1205. @Initial check in.  Preliminary development stage.
  1206. @
  1207. text
  1208. @d4 22
  1209. a25 4
  1210.   $Header$
  1211.   $Author$
  1212.   $Date$
  1213.   $Log$
  1214. d132 1
  1215. a132 1
  1216.   return [ self subclassResponsibility:_cmd ];
  1217. @
  1218.